{include file="public/header-static"/}
{include file="public/sidebar"/}
<div id="main">

    {include file="public/header"/}

    <main class="main-content">

        <div class="container">
            {include file="public/page-header"/}
            <!-- end::page-header -->
            <div class="row">
                <div class="col-md-12">
                    <div class="card">
                        <div class="card-body">
                            <div class="app-block">
                                <div class="app-content">
                                    <div class="app-action">
                                        <div class="action-right" style="margin-left: auto">
                                            <a href="#" class="app-sidebar-menu-button btn btn-outline-light">
                                                <i data-feather="menu"></i>
                                            </a>
                                            <div class="input-group">
                                                <input type="text" name="keywords" id="keywords" autofocus="autofocus" value="{$Request.get.keywords}"  class="form-control" placeholder="搜索关键字[昵称]"
                                                       aria-describedby="button-addon1">
                                                <div class="input-group-append">
                                                    <button class="btn btn-outline-light" type="submit" id="button-addon1">
                                                        <i data-feather="search"></i>
                                                    </button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                                <table id="linkstable" lay-filter="linkstable"></table>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </main>
    {include file="public/footer"/}
</div>
<style>
    #dis{background-color:#d8d6d6;pointer-events: none;}
</style>

<script src="__STATIC__/assets/js/custom.js"></script>

<script>
    function edit(id) {
        window.location.href = '{:url("/console/userEdit")}?id='+id;
    }

    // layui插件
    layui.use('table', function(){
        var table = layui.table
            ,form = layui.form;
        // 表格初始化
        table.render({
            elem: '#linkstable'
            ,url: '{:url("/console/failMember")}'
            ,method:'post'
            ,page: true //开启分页
            ,cols: [[
                {field:'id', title:'ID'}
                ,{field:'headimg', title:'头像', width:80, templet: function(d) { return '<div onclick="show_img(this)" ><img src="'+d.headimg+'" ' + 'alt="" width="60px" height="60px"></a></div>'; }}
                ,{field:'nickname', title:'昵称'}
                ,{field:'id', title:'用户ID'}
                ,{field:'create_time', title:'注册时间'}
                ,{field:'end_time', title:'到期时间'}
            ]],
            done:function (res) {
                var element = $('td[data-field="rightbtn"]').children('.layui-table-cell');
                element.css('overflow','visible');
                element.children('.dropdown-menu').css('min-width','auto');
            },
            parseData: function(res){
                return {
                    "code": res.data.code,
                    "msg": res.data.msg,
                    "count": res.data.count,
                    "data": res.data.list
                };
            }
        });
        table.on('tool(linkstable)', function(obj){
            var data = obj.data;
            if(obj.event === 'del'){
                layer.confirm('删除该数据？', {icon: 3, title:'提示'}, function(index){
                    obj.del();
                    layer.close(index);
                    del(data.id);
                });
            }else if(obj.event === 'edit'){
                edit(data.id);
            }else if(obj.event === 'see'){
                see(data.id);
            }
        });

        // 搜索
        $('#button-addon1').on('click', function(){
            var keywords= $("#keywords").val();
            table.reload('linkstable', {
                url: '{:url("/console/failMember")}'
                ,where: {
                    keywords : keywords // 搜索参数
                }
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });

    });

    // 图片放大
    function show_img(element) {
        var elements = $(element).find("img");
        //页面层
        layer.open({
            type: 1,
            title: '图片',
            anim: 2,
            // area: ['800px','500px'], //宽高 t.width() t.height()
            shadeClose: true, //开启遮罩关闭
            end: function (index, layero) {
                return false;
            },
            content: '<div style="text-align:center"><img src="' + $(elements).attr('src') + '" /></div>'
        });
    }
</script>